package com.fa.common.warehouse;

import com.fa.common.utils.sign.RsaUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class WarehouseCodeCheckValidator implements ConstraintValidator<WarehouseCodeCheck, String> {
    @Override
    public boolean isValid(String warehouseCode, ConstraintValidatorContext constraintValidatorContext) {
        try {
            warehouseCode = RsaUtils.decryptByPrivateKey(warehouseCode);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return warehouseCode.matches("^[A-Z]{2}\\d+");
    }
}
